// src/models.rs
pub struct Product {
    pub name: String,
    pub price: f64,
    sku: String, // 私有字段
}

impl Product {
    pub fn new(name: &str, price: f64) -> Self {
        Product {
            name: name.to_string(),
            price,
            sku: generate_sku(),
        }
    }
    
    pub fn apply_discount(&mut self, ratio: f64) {
        self.price *= 1.0 - ratio;
        println!("已应用{}%折扣", ratio * 100.0);
    }
}

fn generate_sku() -> String {
    // SKU生成逻辑
    String::from("PROD-2023-001")
}

